function minimumOperations(leaves: string): number {
  const len = leaves.length
  let dp = [+(leaves[0] === "y"), Infinity, Infinity]

  for (let i = 1; i < len; i++) {
    const isYellow = leaves[i] === "y"
    dp = [
      dp[0] + +isYellow,
      Math.min(dp[0], dp[1]) + +!isYellow,
      Math.min(dp[1], dp[2]) + +isYellow,
    ]
  }

  return dp[2]
}

export { minimumOperations }
